iconhelper: Don't snapshot 0 sized icons
authorTimm Bäder <mail@baedert.org>
Fri, 9 Aug 2019 13:55:38 +0000 (15:55 +0200)
committerTimm Bäder <mail@baedert.org>
Fri, 9 Aug 2019 13:55:38 +0000 (15:55 +0200)
This is happening for me when snapshotting small thumbnails in the file
chooser. The GtkScaler will scale the 1px height/width by 2, resulting
in nothing being drawn at all.

gtk/gtkiconhelper.c

index a7cf18220f116465c76f82d3ac9804f83fec9b11..5e96bb8e64a29d3ee072e692ba817e2ec1f88b8f 100644 (file)
@@ -219,7 +219,7 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
     case GTK_IMAGE_GICON:
       {
         double x, y, w, h;
-    
+
         /* Never scale up icons. */
         w = gdk_paintable_get_intrinsic_width (self->paintable);
         h = gdk_paintable_get_intrinsic_height (self->paintable);
@@ -228,6 +228,9 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
         x = (width - w) / 2;
         y = (height - h) / 2;
 
+        if (w == 0 || h == 0)
+          return;
+
         if (x  != 0 || y != 0)
           {
             gtk_snapshot_save (snapshot);